#region File Description
//-----------------------------------------------------------------------------
// PhonePauseScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

using System;
using Microsoft.Xna.Framework.Media;
using System.IO.IsolatedStorage;
using Microsoft.Xna.Framework.Content;
namespace OutliersSample
{
    /// <summary>
    /// A basic pause screen for Windows Phone
    /// </summary>
    class PhonePauseScreen : PhoneMenuScreen
    {
        public PhonePauseScreen()
            : base("Paused")
        {
            // Create the "Resume" and "Exit" buttons for the screen
            //11-14-2012 MediaPlayer.Pause();

            Button resumeButton = new Button("Resume");
            resumeButton.Tapped += resumeButton_Tapped;
            MenuButtons.Add(resumeButton);

            Button exitButton = new Button("Exit");
            exitButton.Tapped += exitButton_Tapped;
            MenuButtons.Add(exitButton);
        }

        /// <summary>
        /// The "Resume" button handler just calls the OnCancel method so that 
        /// pressing the "Resume" button is the same as pressing the hardware back button.
        /// </summary>
        void resumeButton_Tapped(object sender, EventArgs e)
        {
            MediaPlayer.Resume();
            OnCancel();
        }

        /// <summary>
        /// The "Exit" button handler uses the LoadingScreen to take the user out to the main menu.
        /// </summary>
        void exitButton_Tapped(object sender, EventArgs e)
        {
            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                                                           new PhoneMainMenuScreen());

            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains("SoundEffectsSetting"))
            {

                //Retrieve data stored in the settings
                string determineFxSettingAfterRelaunch = settings["SoundEffectsSetting"].ToString();

                if (determineFxSettingAfterRelaunch == "false")
                {
                    //11-14-2012 soundFxCanPlay = false;
                   // MediaPlayer.Stop();
                }
                else
                {
                  //11-14-2012  MediaPlayer.Stop();
                   // MediaPlayer.IsRepeating = true; //Groton wakes from coma
                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/OutliersMainMenuMusic"));
                }
            }
            else //if the isolated storage setting hasn't been created yet, then create it and set it to "off" to turn off music.
            {
                //11-14-2012 MediaPlayer.Stop();
                //should only hit this the first time the app is run
                //soundFxCanPlay = true;
            }
        }

        protected override void OnCancel()
        {
            ExitScreen();
            base.OnCancel();
        }
    }
}
